//
//  ViewController.m
//  GuiJuWo
//
//  Created by chenguibang on 16/3/24.
//  Copyright © 2016年 chenguibang. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    UINavigationController *homePageNav = [[UINavigationController alloc]initWithRootViewController:self.homePageC];
    UINavigationController *boutiqueNav = [[UINavigationController alloc]initWithRootViewController:self.boutiqueC];
    UINavigationController *favoritesNav = [[UINavigationController alloc]initWithRootViewController:self.favoritesC];
    UINavigationController *shoppingNav = [[UINavigationController alloc]initWithRootViewController:self.shoppingC];
    UINavigationController *userCenterNav = [[UINavigationController alloc]initWithRootViewController:self.userCenterC];
    self.viewControllers = @[homePageNav,boutiqueNav,favoritesNav,shoppingNav,userCenterNav];
    self.tabBar.tintColor = [UIColor orangeColor];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    [self.mainVM getMainPageInfo];
    
    [RACObserve(self.mainVM, pageInfoRsp) subscribeNext:^(id x) {
//        [self.homePageC.webViewVM loadUrlOnPost:@""];
        self.homePageC.baseurl = self.mainVM.pageInfoRsp[@"body"][@"homeList"][0][@"clickUrl"] == [NSNull null]?nil:self.mainVM.pageInfoRsp[@"body"][@"homeList"][0][@"clickUrl"];
        self.boutiqueC.baseurl = self.mainVM.pageInfoRsp[@"body"][@"homeList"][1][@"clickUrl"] == [NSNull null]?nil:self.mainVM.pageInfoRsp[@"body"][@"homeList"][1][@"clickUrl"];
        self.favoritesC.baseurl = self.mainVM.pageInfoRsp[@"body"][@"homeList"][2][@"clickUrl"] == [NSNull null]?nil:self.mainVM.pageInfoRsp[@"body"][@"homeList"][2][@"clickUrl"];
        self.shoppingC.baseurl = self.mainVM.pageInfoRsp[@"body"][@"homeList"][3][@"clickUrl"] == [NSNull null]?nil:self.mainVM.pageInfoRsp[@"body"][@"homeList"][3][@"clickUrl"];
        self.userCenterC.baseurl = self.mainVM.pageInfoRsp[@"body"][@"homeList"][4][@"clickUrl"] == [NSNull null]?nil:self.mainVM.pageInfoRsp[@"body"][@"homeList"][4][@"clickUrl"];
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(MainVM *)mainVM{
    if (!_mainVM) {
        _mainVM = [[MainVM alloc]init];
        
    }
    return _mainVM;
}

-(HomePageC *)homePageC{
    if (!_homePageC) {
        _homePageC = [[HomePageC alloc]init];
        _homePageC.tabBarItem.title = @"首页";
        _homePageC.tabBarItem.badgeValue = @"5";
        _homePageC.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3);
        _homePageC.tabBarItem.image = [UIImage imageNamed:@"tab_icon01_off"];
        _homePageC.tabBarItem.selectedImage = [UIImage imageNamed:@"tab_icon01_on"];
    }
    return _homePageC;
}

-(BoutiqueC *)boutiqueC{
    if (!_boutiqueC) {
        _boutiqueC = [[BoutiqueC alloc]init];
        _boutiqueC.tabBarItem.title = @"精选";
        _boutiqueC.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3);
        _boutiqueC.tabBarItem.image = [UIImage imageNamed:@"tab_icon02_off"];
        _boutiqueC.tabBarItem.selectedImage = [UIImage imageNamed:@"tab_icon02_on"];
    }
    return _boutiqueC;
}
-(FavoritesC *)favoritesC{
    if (!_favoritesC) {
        _favoritesC = [[FavoritesC alloc]init];
        _favoritesC.tabBarItem.title = @"收藏";
        _favoritesC.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3);
        _favoritesC.tabBarItem.image = [UIImage imageNamed:@"tab_icon03_off"];
        _favoritesC.tabBarItem.selectedImage = [UIImage imageNamed:@"tab_icon03_on"];
    }
    return _favoritesC;
}

-(ShoppingC *)shoppingC{
    if (!_shoppingC) {
        _shoppingC = [[ShoppingC alloc]init];
        _shoppingC.tabBarItem.title = @"购物车";
        _shoppingC.tabBarItem.badgeValue = @"购";
        _shoppingC.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3);
        _shoppingC.tabBarItem.image = [UIImage imageNamed:@"tab_icon04_off"];
        _shoppingC.tabBarItem.selectedImage = [UIImage imageNamed:@"tab_icon04_on"];
    }
    return _shoppingC;
}
-(UserCenterC *)userCenterC{
    if (!_userCenterC) {
        _userCenterC = [[UserCenterC alloc]init];
        _userCenterC.tabBarItem.title = @"我的";
        _userCenterC.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3);
        _userCenterC.tabBarItem.image = [UIImage imageNamed:@"tab_icon05_off"];
        _userCenterC.tabBarItem.selectedImage = [UIImage imageNamed:@"tab_icon05_on"];
    }
    return _userCenterC;
}
@end
